<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .contentBox {
        width: 200px;
        height: 200px;
        background-color: skyblue;
        display: flex;
        align-items: center;
        justify-content: center;
    }
</style>
</head>
<body>
  <div id="app">
    <!-- 选项标题 -->
    <!-- <template v-if="flag"> -->
        <ol >
            <li v-for="(el,idx) in title">
                <span @mouseenter="index=idx">{{el.item}}</span>
                <!-- <span @mouseenter="titleFn(el,idx)">{{el.item}}</span> -->
            </li>
        </ol>
    <!-- </template> -->
    
    <!-- 选项内容 -->
    <div>

        <template v-for="(el,idx) in contents"> 
                <!-- p判断当前最新下标是否和内容下标相同，如果相同就显示出来  -->
                <div class="contentBox" v-show="idx===index">
                    <span >{{el.item}}</span>
                </div>
        </template>
    </div>

</div>

  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el: "#app",
            data: {
                index:0,
                title: [{
                        item: 'html'
                    },
                    {
                        item: 'css'
                    },
                    {
                        item: 'js'
                    },
                    {
                        item: 'vuejs'
                    },
                ],
                contents: [{
                        item: 'html-contents'
                    },
                    {
                        item: 'css-contents'
                    },
                    {
                        item: 'js-contents'
                    },
                    {
                        item: 'vuejs-contents'
                    }
                ]
            },
            // 定义方法
            // methods:{
            //     titleFn($el,$index){
            //         console.log($el,$index);
            //         // 通过this访问当前实例对象的属性和方法
            //         console.log(this.index);
            //         // 将新的下标赋值给初始化下标(记录操作)
            //         this.index=$index
            //     }
            // }
        });
    </script>
</body>
</html>